// Visual Studio Test 2024.h: 标准系统包含文件的包含文件
// 或项目特定的包含文件。

#include <iostream>
#include <stdio.h>
#include <stdlib.h>
#include <windows.h>
#include <conio.h>
#include <map>
#include <string>
#include "Basic_headerfile.h"

// TODO: 在此处引用程序需要的其他标头。

using namespace Windows;

#define ANSI_COLOR_BLUE     "\x1b[34m"
#define ANSI_COLOR_PINK     "\033[38;5;201m"
#define ANSI_COLOR_YELLOW   "\033[38;5;188m"
#define ANSI_COLOR_WHITE    "\033[37m"
#define ANSI_COLOR_RESET    "\x1b[0m"

extern "C" inline const HANDLE __stdcall ChangeKeywordFontColor(const char* str);
extern "C" inline const bool __stdcall SwitchFunctionTrueOrFalse(const char* function);
std::map<std::string, void(*)()> known_functions;
void function() {}

extern "C" inline const HANDLE __stdcall ChangeKeywordFontColor(const char* str) {
    if (strcmp(str, "int") == 0 || strcmp(str, "const") == 0 || strcmp(str, "char") == 0) {
        printf("%s%s%s", ANSI_COLOR_BLUE, str, ANSI_COLOR_RESET);
    }
    else if (strcmp(str, "if") == 0 || strcmp(str, "switch") == 0 || strcmp(str, "for") == 0) {
        printf("%s%s%s", ANSI_COLOR_PINK, str, ANSI_COLOR_RESET);
    }
    else if (SwitchFunctionTrueOrFalse(str) == true) {
        printf("%s%s%s", ANSI_COLOR_YELLOW, str, ANSI_COLOR_RESET);
    }
    else {
        printf("%s%s%s", ANSI_COLOR_WHITE, str, ANSI_COLOR_RESET);
    }
}

extern "C" inline const bool __stdcall SwitchFunctionTrueOrFalse(const char* function_nm) {
    known_functions[function_nm] = function;
    std::string user_input;
    std::getline(std::cin, user_input);
	 
    if (known_functions.find(user_input) != known_functions.end()) {
        return true;
    }
    else {
        return false;
    }
}

extern "C" inline const void __stdcall gotoxy(int x, int y) {
	COORD c;
	c.X = x;
	c.Y = y;
	SetConsoleCursorPosition(GetStdHandle(STD_OUTPUT_HANDLE), c);
}

extern "C" inline const void __stdcall RunBugFind_TF(int Mode) {
    switch (Mode) {
    case TRUE:
        return;
        break;
    case FALSE:
        return (void)EOF;
        break;
    default:
        return (void)(EOF - 1);
        break;
    }
}


//namespace:

namespace VisualStudioTest2024 {
    namespace Windows {
		LRESULT CALLBACK WndProc(HWND hwnd, UINT Message, WPARAM wParam, LPARAM lParam) {
			switch (Message) {

			case WM_DESTROY: {
				PostQuitMessage(0);
				break;
			}

			default:
				return DefWindowProc(hwnd, Message, wParam, lParam);
			}
			return 0;
		}

		int WINAPI CreateWindowMain_Win11(HINSTANCE hInstance, HINSTANCE hPrevInstance, LPSTR lpCmdLine, int nCmdShow) {
			WNDCLASSEX wc;
			HWND hwnd;
			MSG msg;

			memset(&wc, 0, sizeof(wc));
			wc.cbSize = sizeof(WNDCLASSEX);
			wc.lpfnWndProc = WndProc;
			wc.hInstance = hInstance;
			wc.hCursor = LoadCursor(NULL, IDC_ARROW);

			wc.hbrBackground = (HBRUSH)(COLOR_WINDOW + 1);
			wc.lpszClassName = "WindowClass";
			wc.hIcon = LoadIcon(NULL, IDI_APPLICATION);
			wc.hIconSm = LoadIcon(NULL, IDI_APPLICATION);

			if (!RegisterClassEx(&wc)) {
				MessageBox(NULL, "Window Registration Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK);
				return 0;
			}

			hwnd = CreateWindowEx(WS_EX_CLIENTEDGE, "WindowClass", "Caption", WS_VISIBLE | WS_OVERLAPPEDWINDOW,
				CW_USEDEFAULT,
				CW_USEDEFAULT,
				640,
				480,
				NULL, NULL, hInstance, NULL);

			if (hwnd == NULL) {
				MessageBox(NULL, "Window Creation Failed!", "Error!", MB_ICONEXCLAMATION | MB_OK);
				return 0;
			}

			while (GetMessage(&msg, NULL, 0, 0) > 0) {
				TranslateMessage(&msg);
				DispatchMessage(&msg);
			}
			return msg.wParam;
		}
    }

    namespace State {
		using namespace std;
		std::map<std::string, void(*)()> state;
		
		extern "C" inline const int __stdcall MatchExeState(int Mode) {
			if (Mode == 1) {
				return TRUE;
			}
			else if (Mode == 0) {
				return FALSE;
			}
			else{
				return EOF;
			}
		}
    }

	namespace CEMenu {																//Compilation Environment Menu
		#define MatchCompilationType(x) MatchCompilationTypeXY(x)
		extern "C" inline const char* __stdcall MatchCompilationTypeXY(const int choose) {
			printf("编译模式如下：\n");
			printf("1. .NET Aspire\n");
			printf("2. API\n");
			printf("3. Blazor\n");
			printf("4. Blazor Hybrid\n");
			printf("5. Common\n");
			printf("6. Extensions\n");
			printf("7. Iot\n");
			printf("8. Mac Catalyst\n");
			printf("9. MAUI\n");
			printf("10. MSTest\n");
			printf("11. NUnit\n");
			printf("12. Office\n");
			printf("13. Playwright\n");
			printf("14. Roslyn\n");
			printf("15. SQL\n");
			printf("16. Stream Analytics\n");
			printf("17. Tizen\n");
			printf("18. UWP\n");
			printf("19. Web\n");
			printf("20. Web API\n");
			printf("21. WinUI\n");
			printf("22. 测试\n");
			printf("23. 服务\n");
			printf("24. 机器学习\n");
			printf("25. 控制台\n");
			printf("26. 库\n");
			printf("27. 扩展\n");
			printf("28. 其它\n");
			printf("29. 移动\n");
			printf("30. 游戏\n");
			printf("31. 云\n");
			printf("32. 桌面\n");
			error:
			printf("请选择：\n");
			scanf("%d", &choose);

			//TODO:每个序号都有着对应的项目，每个项目都有对应的模板
			switch (choose) {
			case 1:
				break;
			case 2:
				break;
			case 3:
				break;
			case 4:
				break;
			case 5:
				break;
			case 6:
				break;
			case 7:
				break;
			case 8:
				break;
			case 9:
				break;
			case 10:
				break;
			case 11:
				break;
			case 12:
				break;
			case 13:
				break;
			case 14:
				break;
			case 15:
				break;
			case 16:
				break;
			case 17:
				break;
			case 18:
				break;
			case 19:
				break;
			case 20:
				break;
			case 21:
				break;
			case 22:
				break;
			case 23:
				break;
			case 24:
				break;
			case 25:
				break;
			case 26:
				break;
			case 27:
				break;
			case 28:
				break;
			case 30:
				break;
			case 31:
				break;
			case 32:
				break;
			default:
				printf("输入错误！！！\n");
				printf("请重新输入！！！\n");
				goto error;
				break;
			}
		}
	}
}
